<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<%@ include file="/static/include/common.inc"%>
<title>青州市名卡管理系统</title>
<link rel="shortcut icon"
	href="https://github.com/shuaijunlan/Autumn-Framework/raw/master/favicon.ico"
	type="image/x-icon" />
<link rel="stylesheet" href="static/admin/css/layui.css">
<link rel="stylesheet" href="static/admin/css/main.css" media="all">
<script src="static/js/jquery-1.11.2.js"></script>

</head>
<body>
					<ul class="layui-tab-title">
						<li class="layui-this">搜索管理</li>
					</ul>

					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show" style="margin: 10px">

							<div class="buttonTable">
								<blockquote class="layui-elem-quote mylog-info-tit">
									<div class="layui-inline">
										<form class="layui-form" id="userSearchForm">
											<div class="layui-input-inline" style="width: 110px;">
												<select id="searchTerm">
													<option value=""></option>
													<option value="search_id">id</option>
													<option value="search_content">搜素内容</option>
												</select>
											</div>
											<div class="layui-input-inline" style="width: 145px;">
												<input type="text" name="searchContent" value=""
													placeholder="请输入关键字" class="layui-input search_input">
											</div>
										</form>
									</div>
									<div class="layui-inline">
										<button class="layui-btn">查询</button>
									</div>
								</blockquote>
							</div>

							<table class="layui-table"
								lay-data="{ url:'admin/search/load.do', page: true , id:'searchTable'}"
								lay-filter="tablename">
								<thead>
									<tr>
										<!-- <th lay-data="{type:'checkbox', fixed: 'left'}"></th> -->
										<th lay-data="{field:'searchId', }">ID</th>
										<th lay-data="{field:'searchContent',  }">搜素内容</th>
										<th lay-data="{field:'searchCount', }">本月次数</th>
										<th lay-data="{field:'searchHistory', }">历史次数</th>
										<th lay-data="{field:'searchDate', }">最近搜素日期</th>
										<th lay-data="{field:'searchStatus', }">热门搜索状态</th>
										<th
											lay-data="{fixed: 'right', width:356, align:'center', toolbar: '#barDemo'}"></th>
									</tr>
								</thead>
							</table>

							<script type="text/html" id="barDemo">
         <!--   <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reset">重置</a> -->
		</script>
						</div>
					</div>
	<script src="static/layui_v2.2.3/layui.js" charset="utf-8"></script>
	<script>
		layui.use('table', function() {
			var table = layui.table;
			//监听表格复选框选择
			table.on('checkbox(tablename)', function(obj) {
				console.log(obj)
			});
			//监听工具条
			table.on('tool(tablename)', function(obj) {
				var data = obj.data;
				if (obj.event === 'reset') {
					$.ajax({
						url : "admin/search/reset.do",
						data : {
							"searchId" : data.searchId
						},
						type : 'post',
						async : false,//这里表示同步
						error : function(data) {
							console.log(data);
						}
					});

					table.reload('searchTable', {
						page : {
							curr : 1
						//重新从第 1 页开始
						},
					});
				}
			});

			$('.buttonTable .layui-btn').on('click', function() {
				if($("#searchTerm option:selected").val()==""&&$(".search_input").val()!=""){
					layer.msg('请选择查询条件', {icon: 5});
					return false;
				}
				table.reload('searchTable', {
					page : {
						curr : 1
					//重新从第 1 页开始
					},
					where : {
						type : $("#searchTerm option:selected").val(),
						content : $(".search_input").val()
					}
				});

			});
		});
	</script>
</body>
</html>